package com.zpark.controller;

import com.zpark.pojo.Empty;
import com.zpark.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @PackageName: com.zpark.controller
 * @ClassName: UserController
 * @Description:
 * @author: RZS
 * @date: 2022/9/13  11:08
 */
@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService userService;

    @RequestMapping("/find")
    public ModelAndView findAll(){
        // 创建视图解析器
        ModelAndView mv = new ModelAndView();
        // 设置视图名字
        mv.setViewName("demo02");

        // 创建empty对象
        Empty empty = new Empty(10,"冯梓轩", "000", "男", 2.0, "大连");

        // 创建map对象
        Map<String, Object> map = new HashMap<>();
        map.put("empty", empty);
        map.put("con", "Hello Thymeleaf");
        // 调用业务层获取数据
        List<Empty> emptys =  userService.findAllEmpty();

        map.put("lists", empty);

        // 绑定数据
        mv.addObject("maps", map);

        return mv;
    }

}
